//
//  BaseNavigationController.m
//  BaseProject
//
//  Created by 范庆忠 on 2019/7/28.
//  Copyright © 2019 qingzhou. All rights reserved.
//
/**
 实现侧滑返回 遵循UIGestureRecognizerDelegate 并实现代理即可
 */

#import "BaseNavigationController.h"

@interface BaseNavigationController ()<UIGestureRecognizerDelegate>

@end

@implementation BaseNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.interactivePopGestureRecognizer.delegate = self;
    [self configNavigationBar];
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    NSArray *controllers = self.childViewControllers;
    if (controllers.count <= 1) {
        return NO;
    }
    return YES;
}

/**
 这个方法一旦设置就不能更改。慎用
 */
- (void)configNavigationBar {
    /** 两个设置导航栏背景颜色的方式 一、图片渲染 二、直接设置bartintcolor */
    //一、
    UIColor *navigationColor = [UIColor redColor];
    [self.navigationBar setBackgroundImage:[[UIColor createImageWithColor:navigationColor] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forBarMetrics:UIBarMetricsDefault];
    [self.navigationBar setShadowImage:[UIImage new]];
    ///这里最好设置背景
    self.view.backgroundColor = navigationColor;
    //二、 ///这个方法设置的颜色在图片的下方
    [self.navigationBar setBarTintColor:[UIColor redColor]];//设置导航栏背景的颜色
    
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    //设置导航栏title的字体及颜色i
    [self.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor darkGrayColor],NSForegroundColorAttributeName, [UIFont systemFontOfSize:18],NSFontAttributeName , nil]];
}

@end
